package com.javasm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.javasm.domin.entity.CountGoods;
import com.javasm.domin.entity.goods.Goods;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author longjun
 * @since 2022-01-18
 */
public interface CountGoodsMapper extends BaseMapper<CountGoods> {


    /**
     * 根据订单id查询countGoods的数据
     */
    @Select("SELECT count_goods.* FROM count_goods where id =#{id}")
    List<CountGoods> findCountGoodsById(Long id);

    /**
     * 根据订单id查询countGoods的数据
     */
    @Select("SELECT count(*) FROM count_goods where id =#{id} and goods_id=#{goodsId};")
    Integer findCount(@Param("goodsId") Long goodsId,@Param("id") Long id);

    /**
     * 查询所有商品id集合
     */
    @Select("select goods_id from count_goods")
    List<CountGoods> findGoodsidList();


    @Select("select count(*) from count_goods where goods_id =#{goodsId}")
     Integer numberGoods(Long goodsId);


    @Select("select goods_name,product_color_id,brand_id,type_id,product_id from gd_goods where goods_id =#{goodsId}")
    List<Goods> searchGoods(Long goodsId);
}
